import { Login } from "@/api/interface/index";
import { CANROCNET } from "@/api/config/servicePort";
import http from "@/api";

/**
 * 获取验证码
 *
 * @returns 返回验证码
 */
export const getVerifCodeApi = () => {
  return http.get<Login.VerificationCodeResult>(`${CANROCNET}/api/authentication/code`, {}, { loading: false });
};

/**
 * 用户登录
 *
 * @param params 登录表单
 * @returns 返回登录结果
 */
export const loginApi = (params: Login.LoginForm) => {
  return http.post<Login.LoginResult>(`${CANROCNET}/api/authentication/login`, params, { loading: true });
};

/**
 * 用户退出登录
 *
 * @returns void
 */
export const logoutApi = () => {
  return http.post(`${CANROCNET}/api/authentication/logout`);
};
